package web;

import java.util.Calendar;
import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * User: vgonzalez
 * Date: 13/11/12
 * Time: 14:48
 * To change this template use File | Settings | File Templates.
 */
public class CommonUtils {

    public static String parseDDMMYYYY(Date dFecha){
        if(dFecha == null)
            return "";
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(dFecha);
        String anio = Integer.toString(calendar.get(Calendar.YEAR));
        String mes =  Integer.toString(calendar.get(Calendar.MONTH) + 1);
        String dia = Integer.toString(calendar.get(Calendar.DAY_OF_MONTH));
        if(mes.length() == 1)
            mes = "0".concat(mes);
        if(dia.length() == 1)
            dia = "0".concat(dia);
        String fecha = dia + "-" + mes + "-" + anio;
        return  fecha;
    }

    public static String getNewLineString(){
        return System.getProperties().getProperty("line.separator");
    }
}
